package dipl.algorithm.math.geometry;

import dipl.algorithm.math.primitive.Vector2d;
import dipl.algorithm.math.utility.ApfloatUtils;
import org.apfloat.Apfloat;

/**
 *  2d-bound wedge defined by (clockwise)left bounding vector and opening angle.
 * Members of this class are public for faster access. Only access them when reading!
 */
public class BoundingWedge2d {

	//
	// CONSTRUCTOR METHODS
	//

	/**
	 * Construct wedge from given left bounding vector in clockwise direction and opening angle.
	 * Bounding vectors must not have zero length!
	 *
	 * @param left (clockwise)left bounding vector
	 * @param angle opening angle (in radians)
	 */
	public BoundingWedge2d( Vector2d left, Apfloat angle ) {
		this.left       = left;
    this.angle      = angle;
	}

	//
	// PUBLIC METHODS
	//

	/**
	 * Returns whether cone is degenerated.
	 * A cone is degenerated if its opening angle is zero.
	 * @param fpMath
	 * @return degenerated or not
	 */
	public boolean IsDegenerated() {
		return angle.compareTo( Apfloat.ZERO ) == 0;
	}

	@Override
	public String toString() {
		return "["+"left:"+left.toString()+" angle:"+angle.multiply( ApfloatUtils.ValueOf( 1.0/(Math.PI/180.0) ) ).doubleValue()+"°]";
	}

	//
	// MEMBERS
	//

	/** (clockwise) left bounding vector */
	public Vector2d left;
	/** opening angle */
	public Apfloat angle;
}
